<?php
	class Application
	{
		protected $controller;
		protected $task;
		
		public function __construct()
		{
			$this->initController();
			$this->initTask();
		}
		
		public function setController($controller)
		{
			$this->controller=$controller;
		}
		
		public function getController()
		{
			return $this->controller;
		}
		
		public function setTask($task)
		{
			$this->task=$task;
		}
		
		public function getTask()
		{
			return $this->task;
		}
		
		public function initController()
		{
			if(isset($_REQUEST['com']))
			{
				$this->setController($_REQUEST['com']);
			}
			else
			{
				$this->setController('home');
			}
		}
		
		public function initTask()
		{
			if(isset($_REQUEST['task']))
			{
				$this->setTask($_REQUEST['task']);
			}
			else
			{
				$this->setTask('index');
			}
		}
		
		public function run()
		{
			$params=null;
			require(DOCUMENT.'/Controllers/'.$this->getController().'Controller.php');
			if(class_exists($this->getController().'Controller'))
			{
				$class= $this->getController().'Controller';
				$com = new $class();
				if(method_exists($com,$this->getTask().'Action'))
				{
					call_user_method($this->getTask().'Action',$com,$params);
				}
				else
				{
					echo 'This is Bingo\'s HomePage!';
				}
			}
		}
	}
?>